<template>
	<!-- 我的 -->
	<scroll-view scroll-y class="container">
		<view class="header">
			<view class="title-contents">
				<!--  #ifdef APP-PLUS||MP -->
				<view class="top-view status"></view>
				<!--  #endif -->
				<view class="header_pic">
					<image src="/static/images/my/my_bj.png" mode=""></image>
				</view>
				<view class="header_content">
					<view class="header_content_top">
						<!-- #ifndef MP -->
						<!-- 编辑资料 -->
						<text class="iconfont icon-icon_shezhi" @click="go_edit_user"></text>
						<!-- #endif -->
						
					</view>
					<!-- 已登录 -->
					<view class="header_content_perple" v-if="get_user==true">
						<view class="" v-if="userlist.avatar">
							<image :src="userlist.avatar" mode="" style="box-shadow: 0 0 3px 0.5px #e8e8e8;"></image>
						</view>
						<view class="" v-if="userlist.avatar==''">
							<image src="/static/images/my/001.png" mode=""></image>
						</view>
						<view class="">
							<text v-if="userlist.nickname">{{userlist.nickname}}</text>
							<text v-else-if="userlist.nickname==''">您还没有设置昵称</text>
						</view>
					</view>
					<!-- 未登录 -->
					<view class="header_content_perple" v-if="get_user==false">
						<view class="">
							<image src="/static/images/my/001.png" mode=""></image>
						</view>
						<view class="">
							<text @click="go_log">请登录</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="order-section">
			<view class="order-item" @click="goOrder(_status=0)">
				<text class="yticon icon-shouye"></text>
				<text>全部订单</text>
			</view>
			<view class="order-item" @click="goOrder(_status=1)">
				<text class="yticon icon-daifukuan"></text>
				<text>待付款</text>
			</view>
			<view class="order-item" @click="goOrder(_status=2)">
				<text class="iconfont icon-wuliu"></text>
				<text>待发货</text>
			</view>
			<view class="order-item" @click="goOrder(_status=3)">
				<text class="yticon icon-yishouhuo"></text>
				<text>待收货</text>
			</view>
			<view class="order-item" @click="goOrder(_status=6)||goOrder(_status=7)">
				<text class="yticon icon-shouhoutuikuan"></text>
				<text>已完成</text>
			</view>
		</view>

		<view class="my_list">
			<view class="my_list_menu" @click="go_like">
				<text class="iconfont icon-shoucangxuanze" style="font-size: 38upx;"></text>
				<view class="">
					<text>我的收藏</text>
					<text class="iconfont icon-youjiantou"></text>
				</view> 
			</view>
			<view class="my_list_menu" @click="go_addr">
				<text class="yticon icon-dizhi"></text>
				<view class="">
					<text>地址管理</text>
					<text class="iconfont icon-youjiantou"></text>
				</view>
			</view>
			<view class="my_list_menu" @click="navTo('/pages/set/about')">
				<text class="iconfont icon-xin-1"></text>
				<view class="">
					<text>关于我们</text>
					<text class="iconfont icon-youjiantou"></text>
				</view>
			</view>

			<view class="my_list_menu">
				<text class="iconfont icon-dianhua1"></text>
				<view class="">
					<text>联系我们</text>
					<text class="iconfont icon-youjiantou"></text>
				</view>
			</view>
			<view class="my_list_menu" @click="navTo('/pages/set/set')">
				<text class="yticon icon-shezhi1"></text>
				<view class="">
					<text>设置</text>
					<text class="iconfont icon-youjiantou"></text>
				</view>
			</view>
		</view>
	</scroll-view>
</template>
<script>
export default {
	data() {
		return {
			userlist:[],//用户信息
			get_user:false,//是否获取了用户信息
			token:'',
			_status:0,
			host:'https://4de16698-d9f4-443a-b416-ef1037cce952.bspapp.com/http'
		};
	},
	onLoad(e) {
		
	},
	// onShow页面显示就执行
	onShow() {
		// 获取本地数据API
		uni.getStorage({
			key: 'token',
			success: res => {
				// 数据获取成功 用户已登陆
				console.log(res);
			},
			fail: err => {
				// uni.$u.toast("尚未登陆，请先登录")
				console.log('尚未登陆，请先登录');
			}
		});
		this.getuser()
	},
	methods: {
		// 去登陆
		go_log(){
			uni.navigateTo({
				url: '/pages/public/login'
			});
		},
		// 获取用户信息
		getuser(){
			let token=uni.getStorageSync('token')
			this.token=token;
			uni.request({
				method:'POST',
				data:{
					'token':this.token
				},
				url:this.host+'/user/getuserInfo',
				success:(res) => {
					console.log(res);
					this.userlist=res.data.userInfo
					if(this.userlist==undefined){
						this.get_user=false
					}else{
						this.get_user=true
					}
					if(this.userlist==undefined){
						uni.$u.toast("请登录")
						uni.clearStorageSync()
					}
				},
				fail: () => {
					console.log('请求失败');
				} 
			})
		},
		// 前往 订单列表页
		goOrder(_status){
			// 获取本地数据API
			uni.getStorage({
				key: 'token',
				success: res => {
					// 数据获取成功 用户已登陆
					uni.navigateTo({
						url:'/pages/order/order?status='+_status
					})
				},
				fail: err => {
					uni.$u.toast("请先登录")
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			});
		},
		// 修改用户信息
		go_edit_user(){
			// 获取本地数据API
			uni.getStorage({
				key: 'token',
				success: res => {
					// 数据获取成功 用户已登陆
					uni.navigateTo({
						url:'/pages/user/userinfo'
					})
				},
				fail: err => {
					uni.$u.toast("请先登录")
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			});
		},
		// 我的收藏
		go_like(){
			uni.getStorage({
				key: 'token',
				success: res => {
					// 数据获取成功 用户已登陆
					uni.navigateTo({
						url:'/pages/like/likList'
					})
				},
				fail: err => {
					uni.$u.toast("请先登录")
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			});
		},
		// 地址管理
		go_like(){
			uni.getStorage({
				key: 'token',
				success: res => {
					// 数据获取成功 用户已登陆
					uni.navigateTo({
						url:'/pages/address/address'
					})
				},
				fail: err => {
					uni.$u.toast("请先登录")
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			});
		}
		 
	}
};
</script>

<style lang="scss">
page {
	font-size: 28upx;
	background: #f5f5f5;
	.container {
		height: calc(100% - 100upx);
	}
	.header {
		position: relative;
		width: 100%;
		height: 400upx;
		// background-image: url('/static/assets/my/my_bg.png');
		background-size: cover;
		overflow: hidden;
		/*  #ifndef  APP-PLUS  */
		height: 400upx;
		background-size: 100% 100%;
		/*  #endif  */
		.title-contents {
			position: relative;
			top: 0;
			width: 100%;
			height: calc(var(--status-bar-height) + 88upx);
			z-index: 99;
			color: #fff;
			.top-view {
				width: 100%;
				height: var(--status-bar-height);
				background: #fb8173;
			}
			.header_pic {
				width: 100%;
				height: 280upx;
				position: relative;
				image {
					width: 100%;
					max-height: 400upx;
				}
			}
			.header_content {
				position: absolute;
				width: 94%;
				margin: 0 3%;
				top: 50upx;
				.header_content_top {
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					justify-content: flex-end;
					.iconfont {
						font-size: 52upx;
						margin-left: 20upx;
					}
				}
				.header_content_perple {
					height: 120upx;
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					align-items: center;
					font-size: 28upx;
					image {
						width: 120upx;
						height: 120upx;
						margin-right: 30upx;
						border-radius: 50%;
					}
				}
			}
		}
	}

	.order-section {
		display: flex;
		justify-content: space-around;
		align-items: center;
		background: #fff; 
		border-radius: 10upx;
		height: 180upx;
		margin: -120upx auto 0;
		border-radius: 10px;
		width: 96%;
		position: relative;
		z-index: 998;
		background: #fff;
		.order-item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: 24rpx;
		}
		.yticon,
		.iconfont {
			font-size: 48upx;
			margin-bottom: 18upx;
			color: #FDD100;
		}
		.icon-shouhoutuikuan {
			font-size: 44upx;
		}
	}

	.my_list {
		width: 94%;
		margin: 40upx 3% 40upx;
		background: #fff;
		border-radius: 15upx;
		.my_list_menu {
			width: 94%;
			margin: 0 3%;
			height: 100upx;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			align-items: center;
			.iconfont,.yticon {
				width: 15%;
				text-align: center;
				color: #888;
			}
			view {
				width: 85%;
				height: 100upx;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #eeeeee;
				.iconfont {
					text-align: right;
					color: #cbcbcb;
				}
			}
		}
	}
}
</style>
